package com.aloda.orangebank.mapper;

import com.aloda.orangebank.pojo.ChangePwd;
import com.aloda.orangebank.pojo.User;
import org.apache.ibatis.annotations.*;


@Mapper
public interface UserMapper {

    @Insert("INSERT INTO users(username,password,imgUrl,name,phone,mail,create_time,update_time) " +
            "values (#{username},#{password},#{imgUrl},#{name},#{phone},#{mail},#{createTime},#{updateTime})")
    void register(User user);

    @Select("select count(*) from users where username=#{username} ")
    boolean getByUsername(String username);

    @Select("select * from users where username = #{username} and password = #{password}")
    User getByUP(User user);

    @Select("select * from users where id=#{id}")
    User getByUserId(Integer id);


//    @Update("update users set name=#{name} where id=#{id}")//在这里主键ID和注册时间是没有提交的需要动态sql
    boolean updateUser(User user);

    @Update("update users set password=#{newPwd} where id=#{id}")
    void updatePwd(ChangePwd changePwd);
    @Select("select * from users where username=#{username}")
    User getUserByUsername(String username);
}
